<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Tools\Func;
use App\Models\Jiuzhenren;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;


class jiuzhenrenController extends Controller
{
    use Func;

    // 列表
    public function list(Request $request)
    {
        $keywords = trim($request->keywords);
        $data = Jiuzhenren::where(function($query) use($keywords){
			// 关键字
			if ($keywords) {
				$query->orWhere('jiuzhenren_name', $keywords);
				$query->orWhere('phone', $keywords);
				$query->orWhere('idcard', $keywords);
			}
			$query->where('state', 0);
		})->orderBy('id', 'desc')->paginate($request->limit ?? 10);
        return $this->returnJson(0, 'success', $data);
    }
	

    // 删除
    public function del(Request $request)
    {
		if (!Jiuzhenren::where([
			'id' => $request->id,
		])->update([
			'state' => 1,
			'is_default' => 0
		])) {
		    return $this->returnJson(1, '删除失败~', $res);
		}
        return $this->returnJson(0, '删除成功');
    }



}
